//引入
import { ref, reactive } from 'vue'
import axios from 'axios'
export default function () {
  //数据
  let url = 'https://dog.ceo/api/breed/pembroke/images/random'
  let dogList = reactive(['https://images.dog.ceo/breeds/pembroke/n02113023_15998.jpg', 'https://images.dog.ceo/breeds/pembroke/n02113023_5365.jpg', 'https://images.dog.ceo/breeds/pembroke/n02113023_4893.jpg'])
  //方法
  async function addDog() {
    let ret = await axios.get(url)
    console.log(ret.data)
    if (ret.data.status == 'success') {
      dogList.push(ret.data.message)
    }
  }
  //向外部给出数据及方法
  return { dogList, addDog }
}
